package www.openteam.com.presenter.business;


import java.util.HashMap;

import www.openteam.com.base.BasePresenter;
import www.openteam.com.bean.CustomType;
import www.openteam.com.bean.InsertStatus;
import www.openteam.com.bean.QueryCustom;
import www.openteam.com.contract.business.EditCustomInfoContract;
import www.openteam.com.model.business.EditCustomInfoModel;
import www.openteam.com.mvp.IModel;
import www.openteam.com.ui.business.QueryCustomInfoFragment;

/**
 * Created by hyd on 2016/10/16.
 */

public class EditCustomInfoPresenter extends BasePresenter<QueryCustomInfoFragment>
        implements EditCustomInfoContract.QueryCustomInfoPresenter {


    @Override
    public HashMap<String, IModel> getiModelMap() {
        return loadModelMap(new EditCustomInfoModel());
    }

    @Override
    public HashMap<String, IModel> loadModelMap(IModel... models) {
        HashMap<String, IModel> hashMap = new HashMap<>();
        hashMap.put("editCustomInfo", models[0]);

        return hashMap;
    }

    @Override
    public void queryCocustomInfos(String code, String name, String Businessman,int UserID, int PageSize) {

        ((EditCustomInfoModel) getiModelMap().get("editCustomInfo"))
                .queryCocustomInfos(code, name, Businessman,UserID, PageSize, new EditCustomInfoModel.QueryCustomInfoOnListener() {
                    @Override
                    public void queryCISuccess(QueryCustom queryCustom) {


                        getIView().loadCCIData(queryCustom);

                    }

                    @Override
                    public void queryCIFail(Throwable throwable) {
                        getIView().hideCCIData(throwable);

                    }

                });

    }

    @Override
    public void queryMoneyTypeInfo(int pageSize) {
        ((EditCustomInfoModel) getiModelMap().get("editCustomInfo")).queryMoneyTypeInfo(pageSize, new EditCustomInfoModel.QueryMTIOnListener() {
            @Override
            public void queryMTISuccess(CustomType customType) {
                getIView().loadMTIData(customType);
            }

            @Override
            public void queryMTIFail(Throwable throwable) {
                getIView().hideMTIData(throwable);
            }
        });
    }

    @Override
    public void queryCopayTypeInfo(int pageSize) {
        ((EditCustomInfoModel) getiModelMap().get("editCustomInfo"))
                .queryCopayTypeInfo(pageSize, new EditCustomInfoModel.QueryCPTIOnListener() {
                    @Override
                    public void queryCPTISuccess(CustomType customType) {
                        getIView().loadCpTIData(customType);
                    }

                    @Override
                    public void queryCPTIFail(Throwable throwable) {
                        getIView().hideCpTIData(throwable);
                    }
                });
    }

    @Override
    public void queryCocustomTypeInfo(final int pageSize) {


        ((EditCustomInfoModel) getiModelMap().get("editCustomInfo"))
                .queryCocustomTypeInfo(pageSize, new EditCustomInfoModel.QueryCTIOnListener() {
                    @Override
                    public void queryCTISuccess(CustomType customType) {
                        getIView().loadCTIData(customType);
                    }

                    @Override
                    public void queryCTIFail(Throwable throwable) {
                        getIView().hideCTIData(throwable);
                    }
                });
    }

    @Override
    public void deleteCustomInfo(int id) {
        ((EditCustomInfoModel) getiModelMap().get("editCustomInfo"))
                .deleteCustomInfo(id, new EditCustomInfoModel.DelectCustomInfoOnListener() {
                    @Override
                    public void deleteCISuccess(InsertStatus insertStatus) {
                        getIView().deleteCCIData(insertStatus);
                    }

                    @Override
                    public void deleteCIFail(Throwable throwable) {
                        getIView().failCCIData(throwable);
                    }
                });
    }
}
